<?php

namespace App\Http\Controllers\H5;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;

class CardController extends BaseController
{
    public function index()
    {

        return $this->view('h5.user.card');
    }

    public function store(Request $request)
    {
        $card = $request->input('card');
        if ($card)
        {
            $card = array_only($card, [
                'name',
                'phone',
                'type',
                'bank',
                'account_id',
                'branch'
            ]);

            $this->user()->bankCards()->create($card);
        }

        return ajaxReturn();
    }

    public function getJson(Request $request)
    {
        $items = $this->user()->bankCards()->orderBy('id')->get();
        return ajaxReturn(['items'=>$items]);
    }
}
